<template>
  <div class="special">
   <!-----头部+导航----->
     <div class="special_head">
       <div class="special_menu">
           <ul class="flex flex-space-around">
               <li v-for="item in navList">
                 <a v-if="item.id" :href="item.href + '?catid=' + item.id" target="_blank">
                   {{ item.name }}
                 </a> 
                 <a v-else :href="item.href" target="_blank">
                   {{ item.name }}
                 </a>                   
               </li>
           </ul>
       </div>
     </div>

     <div class="email_cont clearfix">
          <div class="email_list fl">
            <h1>意见列表</h1>
            <!-- <div class="email_search flex flex-align-center flex-pack-justify">
              <div class="select_search flex flex-align-center">
                <el-input v-model="inputValue" placeholder="请输入关键字"></el-input>
                <el-button type="danger" style="margin-left:15px" @click="goSearch">查询</el-button>
              </div>
            </div> -->
            <div class="email_data">
              <ul v-if="dataList.length > 0">
                <li v-for="(item,index) in dataList">
                  <h2 class="ys">{{item.title}}</h2>
                  <div class="time flex" >
                    <div><i class="iconfont icon-shijian"></i>{{item.liuyanshijian}}</div>
                  </div>
                  <div class="answer">{{item.content}}</div>
                </li>
              </ul>
              <el-empty v-if="dataList.length <= 0" description="暂无数据"></el-empty>               
            </div>

            <div v-if="dataList.length <= 0" class="page" style="text-align:center;margin-top:30px;">
                <el-pagination
                  :small="true"
                  :background="true"
                  @current-change="handleSizeChange"
                  :current-page="pageindex" 
                  :page-size="pagesize" 
                  layout="total,prev, pager, next,jumper"
                  :total="retotal"
                  prev-text="<上一页"
                  next-text="下一页>"
                  >
                </el-pagination>  
              </div>

          </div>
          <div class="my_message fr">
            <!-- <div class="xuzhi">
              <p>留言须知：</p>
              <p>1.信箱留言应严格遵守法律法规及社会公德，不得捏造、歪曲事实；不得诋毁、辱骂他人；不得煽动民族、宗教、种族、地域等敏感问题；不得散布淫秽、色情、暴力等不良信息。对于违反法律法规的留言行为，留言者自行承担相应的法律责任。 </p>
              <p>2.信箱留言人应当自觉遵守互联网礼仪，进行理性、真诚、友善的互动交流，不得发表人身攻击等激化矛盾的言论；不得进行恶意刷屏等破坏秩序的行为，同时，应当尊重他人的合法权益，不得侵犯他人的隐私、名誉等。</p>
              <p>3.领导信箱是医院官兵员工向院领导提出意见和建议的渠道之一，对于所反映问题，建议首先与医院相关部门联系沟通，了解实际情况，并寻求解决措施。 </p>
              <p>4.为便于及时准确地了解留言诉求，建议准确详细地描述所反映的问题，并根据各职能部门职责范围，@相应部门进行留言，以便有针对性地解决您反映的问题。留言成功后，所涉部门会及时接收，按规定报送、处理并原则上于三日内反馈处理情况。在此期间，请不要重复提交。</p>
            </div> -->
            <div class="form">
              <el-form ref="form" :model="form" label-width="80px" label-position="top">
                <!-- <el-row :gutter="20"> -->
                  <!-- <el-col :span="12">
                    <el-form-item label="昵称">
                      <el-input></el-input>
                    </el-form-item>
                  </el-col> -->
                  <!-- <el-col :span="12">
                    <el-form-item label="联系方式">
                      <el-input></el-input>
                    </el-form-item>
                  </el-col> -->
                <!-- </el-row> -->
                <el-form-item label="标题">
                  <el-input v-model="form.title"></el-input>
                </el-form-item>
                <el-form-item label="内容">
                  <el-input v-model="form.content" type="textarea" :rows="6"></el-input>
                </el-form-item>
                <el-row style="padding-top:20px">
                  <!-- <el-col :span="12">
                    <el-form-item>
                      <el-checkbox v-model="form.shifouyinsi">是否隐私</el-checkbox>
                    </el-form-item>  
                  </el-col>   -->
                  <el-col :span="12" style="text-align:right">
                    <el-form-item>
                      <el-button type="danger" @click="submit('form')">发表</el-button>
                    </el-form-item>  
                  </el-col>
                </el-row>  
              </el-form>  
            </div>

          </div>
        </div>



     <!------ 底部-------->
     <div class="special_foot">
         <div class="foot_cont flex flex-space-around">
             <span>版权所有：东部战区总医院</span>
             <span>技术支持：医学信息数据室</span>
         </div>
     </div>


  </div> 
</template>
<script setup name="eight">
import { getMenu } from "@/api/yxzx/menu";
import { sendNote, getNote } from "@/api/yxzx/email";
import { listpassInfo } from "@/api/yxzx/info";
export default {
 components: {
 },
 data() {
   return {
       navList:[
           {name: '首页', href:'eight'},
           {name: '通知公告',id: '', href:'/list'},
           {name: '学习教育资料',id: '', href:'/list'},
           {name: '工作开展动态情况',id: '', href:'/list'},
           {name: '意见建议',href:'/note'}
       ],
       inputValue: '',
      pageindex: 1,
      pagesize: 6,
      queryParams:{
        pageindex: 1,
        pagesize: 10,
        ishuifu: 2,
        neirong: '',
      },
      retotal: 0,
      dataList: [],
      form:{
        zhonglei: '',
      },
   }
 },
 computed: {},
 created() {
  this.getData()
 },
 methods: {
  // 查询邮箱数据
  getData(){
    getNote(
      this.queryParams.pageindex,this.queryParams.pagesize
      ).then((response) => {
        this.dataList = response.rows
        this.retotal = response.total
    });
  },
  // 查询按钮操作
  goSearch(){
    if(this.inputValue==''){
      this.$message.error('请输入关键字！');
      return
    }
    this.queryParams.pageindex = 1
    this.queryParams.neirong = this.inputValue
    this.getData()
  },
   // 发表留言
   submit(name){
      if(!this.form.content || this.form.content==''){
        this.$message.error('请填写留言内容！');
        return
      }
      if(this.form.shifouyinsi == true){
        this.form.shifouyinsi = '1'
      } else {
        this.form.shifouyinsi = '0'
      }
      sendNote(
        this.form.title,
        this.form.content,
        ).then((response) => {
          this.$message({
            message: '意见发表成功！',
            type: 'success'
          });
          this.form.title = ''
          this.form.content = ''
          this.$refs['form'].resetFields();
          this.queryParams.pageindex = 1
          this.getData()
      });
    },
   // 分页操作
   handleSizeChange(val){
      this.queryParams.pageindex = val
      this.getData()
    },

 }
} 
</script>